 #include <stdio.h>
 int main()
 {
 	long a,b,yu=1,a1,b1;
	scanf("%ld%ld",&a,&b);
	scanf("%ld%ld",&a1,&b1);
	while(yu!=0)
	{
		yu=a%b;
		a=b;
		b=yu;
	}
	printf("%ld\n",a);
	while(a1!=b1)
	{
		if(a1>b1)
			a1=a1-b1;
		else
			b1=b1-a1;
	}
	printf("%ld\n",a1);
 	return 0;
 }
